using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BUS;
using Utility;
using Entities;

public partial class Admin_Themtour : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loaddropdownlist();
        }
    }
    private void loaddropdownlist()
    {
        dr_tenlt.DataSource = tbLoaitourBUS .GetAll();
        dr_tenlt .DataTextField = tbLoaitourCollumn .tenloaitour .ToString();
        dr_tenlt.DataValueField = tbLoaitourCollumn .maloaitour .ToString();
        dr_tenlt.DataBind();
        dr_tenlt.Items.Insert(0, new ListItem("All", "0"));
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

        //try
        //{
        tbTour  tour = new tbTour ();
        tour.Tentour  = txttent.Text;
        tour.Maloaitour  = int.Parse(dr_tenlt.SelectedValue);

        tour.Thoigian = txt_tg .Text;
        tour.Phuongtien = txt_pt.Text;
        tour .Gia  = float.Parse(txt_g .Text);
        tour.Khoihanh = txt_kh.Text;
        tour.Mota = txt_mota.Text;

        if (img_t.HasFile)
        {
            string filename = DateTime.Now.Ticks.ToString() + "_" + img_t.FileName;
            img_t.SaveAs(Server.MapPath("~/Hinhanh/" + filename));
            System.Drawing.Image img = System.Drawing.Image.FromFile(
                Server.MapPath("~/Hinhanh/" + filename));
            ImageUtility.MakeThumbnailPhoto(
                img, 100, 100, Server.MapPath("~/Hinhanh/Hinh/"), filename);
            tour.Hinh  = filename;
        }
        else
        {
            tour.Hinh  = "no_images.jpg";
        }
        tbTourBUS .Insert(tour);

        Response.Redirect("~/Admin/Danhsachtour.aspx");
        //}
        //catch
        //{
        //    Response.Redirect("~/Admin/D_Sanphamdoanhnghiep.aspx?id=" + mdn.ToString());
        //}
    }
}
